<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateVoiceCallTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('voice_call', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('拨打用户ID');
            $table->integer('chat_user_id')->default(0)->comment('接听用户ID');
            $table->string('channel_id', 32)->default('')->comment('频道ID');
            $table->integer('call_time')->default(0)->comment('语聊时间（秒）');
            $table->tinyInteger('status')->default(1)->comment('0:未接通;1:已接通-正常挂断;2:已接通-异常挂断');
            $table->integer('start_time')->default(0)->comment('发起通话时间');
            $table->integer('answer_time')->default(0)->comment('接听时间');
            $table->integer('end_time')->default(0)->comment('通话结束时间');
            $table->timestamps();
            $table->index('user_id', 'user_id');
            $table->index('channel_id', 'channel_id');
            $table->index('chat_user_id', 'chat_user_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('voice_call');
    }
}
